package cn.jkgly.accessToken.controller;

import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import cn.jkgly.accessToken.entity.AccessToken;
import cn.jkgly.accessToken.service.IAccessTokenService;
import cn.jkgly.wxUser.entity.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

 /**
 * @Description: 健康管理云access_token
 * @Author: jeecg-boot
 * @Date:   2020-10-22
 * @Version: V1.0
 */
@Slf4j
@Api(tags="健康管理云access_token")
@RestController
@RequestMapping("/accessToken/accessToken")
public class AccessTokenController  {
	@Autowired
	private IAccessTokenService accessTokenService;
	

	/**
	 * 添加
	 *
	 * @param accessToken
	 * @return
	 */
	@ApiOperation(value="健康管理云access_token-添加", notes="健康管理云access_token-添加")
	@PostMapping(value = "/add")
	public Result<?> add(@RequestBody AccessToken accessToken) {
		accessTokenService.save(accessToken);
		return Result.ok("添加成功！");
	}
	
	/**
	 * 编辑
	 *
	 * @param accessToken
	 * @return
	 */
	@ApiOperation(value="健康管理云access_token-编辑", notes="健康管理云access_token-编辑")
	@PutMapping(value = "/edit")
	public Result<?> edit(@RequestBody AccessToken accessToken) {
		accessTokenService.updateById(accessToken);
		return Result.ok("编辑成功!");
	}
	
	/**
	 * 通过id删除
	 *
	 * @param id
	 * @return
	 */
	@ApiOperation(value="健康管理云access_token-通过id删除", notes="健康管理云access_token-通过id删除")
	@DeleteMapping(value = "/delete")
	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
		accessTokenService.removeById(id);
		return Result.ok("删除成功!");
	}
	
	/**
	 * 批量删除
	 *
	 * @param ids
	 * @return
	 */
	@ApiOperation(value="健康管理云access_token-批量删除", notes="健康管理云access_token-批量删除")
	@DeleteMapping(value = "/deleteBatch")
	public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		this.accessTokenService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.ok("批量删除成功！");
	}
	
	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	@ApiOperation(value="健康管理云access_token-通过id查询", notes="健康管理云access_token-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
		AccessToken accessToken = accessTokenService.getById(id);
		return Result.ok(accessToken);
	}


}
